//@author A0078695H
#include "CmdUpdate.h"
class Parser;
#include "Parser.h"
#include "logger.hpp"

const string CmdUpdate::UPDATE_PROMPT = "Please edit the task: ";

CmdUpdate::~CmdUpdate(void)
{
}
CmdUpdate::CmdUpdate(cmdTypes cmdType, vector<string> params, string origStr, int id): 
	Cmd(cmdType, params, origStr) {

		
		log(LOG_BY) << "in update construct";
		for (int i=0; i<params.size(); i++) {
			log(LOG_BY) << i;
			log(LOG_BY) << params[i];
		}
		
		if (params.size() == 1) {
			udtType = UdtType::SELECT;
			this->modifiedTask = Task(false);
		}
		else {
			udtType = UdtType::EDIT;
			Task newTask = Parser::stringToTask(params[1]);
			this->modifiedTask = newTask;
		}
		this->id = id;
}
CmdUpdate::CmdUpdate(cmdTypes cmdType, vector<string> params, string origStr, int id, Task task): 
	Cmd(cmdType, params, origStr) {
		if (params.size() == 1) {
			udtType = UdtType::SELECT;
			this->modifiedTask = Task(false);
		}
		else {
			udtType = UdtType::EDIT;
			this->modifiedTask = task;
		}
		this->id = id;
}

int CmdUpdate::getId() {
	return id;
}
void CmdUpdate::setId(int index) {
	id = index;
}

UdtType CmdUpdate::getUdtType() {
	return this->udtType;
}

Task CmdUpdate::getModifiedTask() {
	return this->modifiedTask;
}